package com.wf.course.web;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import com.wf.course.model.user.User;

/**
 * 常用属性类
 * 
 */
public class Constants {

	/**
	 * 当前登录用户
	 */
	public static Map<String, User> LOGIN_USER = new HashMap<>();
	// 阿里云分布式存储信息
	public static String OSS_ACCESS_ID = "";
	public static String OSS_ACCESS_KEY = "";
	public static String IGM_BUCKET = "";
	// 访问地址限制
	public static String IPADDRESS = "";
	// H5页面存储地址
	public static String H5Pages = "";
	// H5页面访问域名
	public static String H5URL = "";
	// 活动
	public static String Activity = "";
	// 广告
	public static String AdInfo = "";
	// 对外开放API接口的可访问IP
	public static String ALLOWAPI_IP = "";

	// OSS 的endpoint
	public static String OSS_ENDPOINT = "";
	// OSS的对外访问地址
	public static String OSSURL = "";
	
	
	//云通讯 短信平台 服务器地址
	public static String YTX_SERVER = "";
	//云通讯 短信平台 端口号
	public static String YTX_PORT = "";
	//云通讯 短信平台主账户
	public static String ACCOUNT_SID = "";
	//云通讯 短信平台主账号令牌
	public static String ACCOUNT_TOKEN = "";
	//云通讯 短信平台应用ID
	public static String APP_ID = "";
	//云通讯 短信平台 短信模板ID
	public static String TEMP_ID = "";
	
	//对账单保存路径
	public static String BILLPATH = "";
	
	

	// 使用静态代码块读取properties文件
	static {

		try {
			Resource resource = new ClassPathResource("/global.properties");
			Properties props = PropertiesLoaderUtils.loadProperties(resource);

			OSS_ACCESS_ID = (String) props.get("OSS_ACCESS_ID");
			OSS_ACCESS_KEY = (String) props.get("OSS_ACCESS_KEY");
			IGM_BUCKET = (String) props.get("IGM_BUCKET");
			IPADDRESS = (String) props.get("ipaddress");
			H5Pages = (String) props.get("H5Pages");
			H5URL = (String) props.get("H5URL");
			Activity = (String) props.get("Activity");
			AdInfo = (String) props.get("AdInfo");
			ALLOWAPI_IP = (String) props.get("ALLOWAPI_IP");

			OSS_ENDPOINT = (String) props.get("OSS_ENDPOINT");

			OSSURL = (String)props.get("OSSURL");
			
			YTX_SERVER = (String)props.get("YTX_SERVER");
			YTX_PORT = (String)props.get("YTX_PORT");
			ACCOUNT_SID = (String)props.get("ACCOUNT_SID");
			ACCOUNT_TOKEN = (String)props.get("ACCOUNT_TOKEN");
			APP_ID = (String)props.get("APP_ID");
			TEMP_ID = (String)props.get("TEMP_ID");
			
			BILLPATH =  (String)props.get("BILLPATH");

		} catch (Exception e) {
			// TODO: handle exception
		}

	}
}
